import ZLXRequest from './request'
import { BASE_URL } from './request/config'
import LocalCache, { CacheKey } from '@/utils/cache'
// 可以 new 多个 axios 实例
// const request2 = new ZLXRequest({
//   baseURL: BASE_URL2,
//   timeout: 10000
// })
const request = new ZLXRequest({
  baseURL: BASE_URL,
  timeout: 5000,
  interceptors: {
    request: (config: any) => {
      // 携带 Token
      const Token = LocalCache.getItem(CacheKey.TOKEN)
      if (Token) config.headers.Authorization = `Bearer ${Token}`
      return config
    }
  }
})
export default request
